﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <link href="~/Content/Css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="~/Content/Css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="~/Content/Css/animate.css" rel="stylesheet">
    <link href="~/Content/Css/style.css?v=4.1.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/jsTree/style.min.css" rel="stylesheet">
    <link href="~/Content/Css/plugins/iCheck/custom.css" rel="stylesheet">
    <style>
        .inp {
            width: 177px;
            padding: 2px 4px;
            display: inline;
        }

        .lab {
            margin-bottom: 5px;
            font-weight: 700;
            cursor: default;
            width: 80px;
            text-align: center;
        }

        /*.sel {
            width: 100px;
            padding: 1px 4px;
            display: inline;
            font-size: 12px;
        }

        .sel-min {
            width: 82.5px;
            padding: 1px 4px;
            display: inline;
            font-size: 12px;
        }*/

        .mybtn-group {
            margin-top: -4px;
        }

        .displayNone {
            display: none;
        }
    </style>
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>中介信息</h5>
            </div>
            <div class="ibox-content" style="padding-bottom: 20px;display">
                <div class="row row-lg">

                    <div class="col-sm-12">
                        @*<div class="col-sm-12">*@
                            <form id="mainForm">

                                @*<input id="repeatPhone" name="repeatPhone" type="hidden" value="false" />*@
                                <div id="toolbar">

                                    <label class="lab">中介名称</label>
                                    <input type="text" class="form-control inp" id="Name" name="Name">
                                    <label class="lab">中介地址</label>
                                    <input type="text" class="form-control inp" id="Address" name="Address">
                                    
                                    <div class="btn-group mybtn-group" style="padding-top:5px;">
                                        <button class="btn btn-white btn-xs" type="submit">查询</button>&nbsp;
                                        <button class="btn btn-primary btn-xs" type="reset">清空</button>
                                    </div>

                                </div>
                                @*<input id="orderBy" name="orderBy" type="hidden" />
                                    <input id="orderByType" name="orderByType" type="hidden" />*@
                            </form>
                        @*</div>*@
                        
                    </div>
                    <div class="col-sm-12">
                        @*<div class="col-sm-12">*@
                            <div class="btn-group">
                                <button id="selBtn" type="button" class="btn btn-info" title="选择中介">
                                    选择中介
                                </button>
                            </div>
                        @*</div>*@
                    </div>
                </div>

                <div class="row">
                    @*<div class="col-sm-12 displayNone" style="padding:15px 15px 15px 15px">

                        </div>*@
                    <div class="col-sm-12">
                        <table id="table"></table>
                    </div>

                </div>
            </div>

        </div>
    </div>



    @*<div id="selectParmeter" style="display:none">
            <div class="col-sm-12">
                <form class="form-horizontal m-t" id="mainForm2" novalidate="novalidate">
                    <div class="form-group">

                        <label class="col-xs-3 control-label">
                            <label class="checkbox-inline i-checks">
                                <input type="checkbox" value="option1" checked="checked" id="selectParmeter_tradeType">交易
                                <select id="houseTradeType" style="display:none"></select>
                            </label>
                        </label>
                        <label class="col-xs-3 control-label">
                            <label class="checkbox-inline i-checks">
                                <input type="checkbox" value="option1" checked="checked" id="selectParmeter_areaId">城区
                            </label>
                        </label>
                        <label class="col-xs-3 control-label">
                            <label class="checkbox-inline i-checks">
                                <input type="checkbox" value="option1" checked="checked" id="selectParmeter_streetId">片区
                            </label>
                        </label>
                        <label class="col-xs-3 control-label">
                            <label class="checkbox-inline i-checks">
                                <input type="checkbox" value="option1" checked="checked" id="selectParmeter_purpose">用途
                            </label>
                        </label>

                    </div>

                    <div class="form-group">
                        <label class="col-xs-3 control-label">
                            <label class="checkbox-inline i-checks">
                                <input type="checkbox" value="option1" checked="checked" id="selectParmeter_scale">房型
                            </label>
                        </label>
                        <label class="col-xs-3 control-label">
                            <label class="checkbox-inline i-checks">
                                <input type="checkbox" value="option1" checked="checked" id="selectParmeter_floor">楼层
                            </label>
                        </label>
                        <label class="col-xs-3 control-label">
                            <label class="checkbox-inline i-checks">
                                <input type="checkbox" value="option1" checked="checked" id="selectParmeter_square">面积
                            </label>
                        </label>
                        <label class="col-xs-3 control-label">
                            <label class="checkbox-inline i-checks">
                                <input type="checkbox" value="option1" checked="checked" id="selectParmeter_price">价格
                            </label>
                        </label>

                    </div>

                    <div class="form-group" style="margin-bottom:0px">
                        <div class="col-xs-3">

                        </div>
                        <div class="col-xs-9">
                            <button id="submit" class="btn btn-primary pull-right" type="submit">
                                <i class="fa fa-check"></i>&nbsp;提&nbsp;交
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>*@





    <script src="~/Scripts/jquery.min.js?v=2.1.4"></script>
    <script src="~/Scripts/bootstrap.min.js?v=3.3.6"></script>
    <script src="~/Scripts/plugins/layer/layer.min.js"></script>

    <script src="~/Scripts/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="~/Scripts/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="~/Scripts/common.js"></script>
    <script src="~/Scripts/plugins/layer/laydate/laydate.js"></script>
    <script src="~/Scripts/plugins/iCheck/icheck.min.js"></script>
    <script>
        //$(".down").click(function (event) {
        //    $('.dropdown-menu').hide();
        //    $(this).parent().find('.dropdown-menu').show();
        //    event.stopPropagation();
        //    $(parent.document).click(function () {
        //        $(".dropdown-menu").hide();
        //    });
        //    $(document).click(function () {
        //        $(".dropdown-menu").hide();
        //    });
        //    $(".dropdown-menu a").click(function () {
        //        $(this).parent().parent().hide();
        //    });
        //});
        //$('.i-checks').iCheck({
        //    checkboxClass: 'icheckbox_square-green',
        //    radioClass: 'iradio_square-green',
        //});

        //function searchSenior() {
        //    if ($("#searchSeniorDiv").is(':visible')) {
        //        $(".border2").css("height", "34px");
        //        $("#searchSeniorDiv").hide();
        //    } else {
        //        $(".border2").css("height", "112px");
        //        $("#searchSeniorDiv").show();
        //    }
        //}

        //laydate({
        //    elem: '#beginDate',
        //    format: 'YYYY-MM-DD', // 分隔符可以任意定义，该例子表示只显示年月
        //    festival: true, //显示节日
        //    max: laydate.now(), //设定最小日期为当前日期
        //    min: '2010-01-01 00:00:00', //最大日期
        //    choose: function (datas) { //选择日期完毕的回调
        //        //alert('得到：' + datas);
        //    }
        //});
        //laydate({
        //    elem: '#endDate',
        //    start: laydate.now(),
        //    format: 'YYYY-MM-DD', // 分隔符可以任意定义，该例子表示只显示年月
        //    festival: true, //显示节日
        //    max: laydate.now(), //设定最小日期为当前日期
        //    min: '2010-01-01 00:00:00', //最大日期
        //    choose: function (datas) { //选择日期完毕的回调
        //        //alert('得到：' + datas);
        //    }
        //});
        //function selectDate(day) {
        //    var mydate = new Date();
        //    var endDate = "" + mydate.getFullYear() + "-";
        //    endDate += (mydate.getMonth() + 1) + "-";
        //    endDate += mydate.getDate();
        //    $("#endDate").val(endDate);

        //    if (day == -1) {
        //        mydate.setYear(mydate.getFullYear() - 20);
        //    } else {
        //        mydate.setDate(mydate.getDate() - day);
        //    }


        //    var beginDate = "" + mydate.getFullYear() + "-";
        //    beginDate += (mydate.getMonth() + 1) + "-";
        //    beginDate += mydate.getDate();
        //    $("#beginDate").val(beginDate);
        //}


        //function QuickBtn(obj) {
        //    var val = 0;
        //    if (obj.type == "button") {
        //        val = $(obj).attr("tradeName");
        //    } else {
        //        val = $(obj).parent().parent().prev().prev().attr("tradeName");
        //    }
        //    selectDate($(obj).attr("value"));
        //    $("#tradeType").val(val);

        //}
        //function QuickStatusBtn(obj) {

        //    $("#status").val($(obj).attr("value"));
        //}
        var $table = $("#table");

        $("#mainForm").submit(function () {
            $table.bootstrapTable('refresh');
            return false;
        });

        $(function () {

            //1.初始化Table

            var table_columns = [
                {
                    width: 38,
                    field: 'selected',
                    checkbox: true,
                }, {
                    field: 'no',
                    title: '行号',
                    align: 'center',
                    formatter: function (value, row, index) { return index + 1; }
                }, {
                    field: 'name',
                    title: '中介名称',
                    align: 'center'
                }, {
                    field: 'address',
                    title: '中介地址',
                    align: 'center'
                }, //{
                //    field: 'id',
                //    align: 'center',
                //    title: '执照图片',
                //    events: operateEvents,
                //    formatter: operateFormatter
                //},
                {
                    field: 'createTime',
                    title: '添加时间',
                    align: 'center'
                }, {
                    field: 'publicAccountBank',
                    title: '对公帐户开户银行',
                    align: 'center'
                }, {
                    field: 'publicAccountUserName',
                    title: '对公帐户开户名',
                    align: 'center'
                }, {
                    field: 'publicAccountNumber',
                    title: '对公帐户开户帐号',
                    align: 'center'
                }, {
                    field: 'privateAccountBank',
                    title: '对私帐户开户银行',
                    align: 'center'
                }, {
                    field: 'privateAccountUserName',
                    title: '对私帐户开户名',
                    align: 'center'
                }, {
                    field: 'privateAccountNumber',
                    title: '对私帐户开户帐号',
                    align: 'center'
                }, {
                    field: 'remark',
                    title: '备注',
                    align: 'center'
                }
            ];

            var orderBy = "";
            var table_queryParams = function (params) {
                var data = {};
                if (parent.CustomerSource_Index_data != undefined) {
                    data = parent.CustomerSource_Index_data;
                } else {
                    data = $("#mainForm").formToJson(false);
                }
                parent.CustomerSource_Index_data = undefined;
                data.pageIndex = (params.offset / params.limit) + 1;
                data.pageSize = params.limit;
                data.orderBy = this.sortName;
                data.orderByType = this.sortOrder;

                return data;
            };

            $table.initTable("/User/IntermediaryIndexAsync", table_columns, 180, table_queryParams);

            //选择中介
            $("#selBtn").click(function () {

                var selected = $table.bootstrapTable('getSelections');

                if (selected.length > 1) {
                    layer.msg("只能选择一条数据！", { icon: 5, time: 2000 });
                    return;
                }

                if (selected.length == 0) {
                    layer.msg("请选择数据！", { icon: 5, time: 2000 });
                    return;
                }
                selData(selected[0].id, selected[0].name);

            });

            function selData(id, name) {

                //传值
                var body = parent.layer.getChildFrame('body', '@ViewData["layerindex"]');
                body.find('#IntermediaryName').val(name);
                body.find('#IntermediaryID').val(id);

                //关闭
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);

            }

            //$.post("/HouseSource/UserDictionaryLoad", function (data) {
            //    if (data.type == 1) {
            //        data = data.data;
            //        $("#areaId").empty();
            //        $("#areaId").append(' <option value="0">全部</option>');
            //        for (var i = 0; i < data.area.length; i++) {
            //            $("#areaId").append(' <option value="' + data.area[i].id + '">' + data.area[i].text + '</option>');
            //        }
            //        $("#streetId").attr("disabled", "disabled");
            //        $("#areaId").change(function () {
            //            $("#streetId").empty();
            //            $("#streetId").append(' <option value="0">全部</option>');
            //            if ($(this).val() == 0) {
            //                $("#streetId").attr("disabled", "disabled");
            //            } else {
            //                $("#streetId").attr("disabled", false);
            //            }

            //            $.post("/HouseSource/StreetList", { areaid: $(this).val() }, function (data) {
            //                if (data.type == 1) {
            //                    for (var i = 0; i < data.data.length; i++) {
            //                        $("#streetId").append(' <option value="' + data.data[i].id + '">' + data.data[i].text + '</option>');
            //                    }
            //                }
            //            });
            //        });


            //        $("#tradeType").empty();
            //        $("#tradeType").append(' <option value="0">全部</option>');
            //        for (var i = 0; i < data.tradeType.length; i++) {
            //            if ($("#lease").text() == data.tradeType[i].text) {
            //                $("#lease").attr("tradeName", data.tradeType[i].id);
            //            }
            //            if ($("#sale").text() == data.tradeType[i].text) {
            //                $("#sale").attr("tradeName", data.tradeType[i].id);
            //            }
            //            $("#tradeType").append(' <option value="' + data.tradeType[i].id + '">' + data.tradeType[i].text + '</option>');
            //        }

            //        $("#status").empty();
            //        $("#status").append(' <option value="0">全部</option>');
            //        var down = $("#statusBtn").next().next();
            //        down.find("li").remove();
            //        for (var i = 0; i < data.dataStuse.length; i++) {
            //            $("#status").append(' <option value="' + data.dataStuse[i].id + '">' + data.dataStuse[i].text + '</option>');
            //            down.append('<li><a class="font-bold" value="' + data.dataStuse[i].id + '" onclick="QuickStatusBtn(this)">' + data.dataStuse[i].text + '</a></li>');
            //        }

            //        $("#purpose").empty();
            //        $("#purpose").append(' <option value="0">全部</option>');
            //        for (var i = 0; i < data.purpose.length; i++) {
            //            $("#purpose").append(' <option value="' + data.purpose[i].id + '">' + data.purpose[i].text + '</option>');
            //        }


            //        $("#buildingType").empty();
            //        $("#buildingType").append(' <option value="0">全部</option>');
            //        for (var i = 0; i < data.purpose.length; i++) {
            //            $("#buildingType").append(' <option value="' + data.buildingType[i].id + '">' + data.buildingType[i].text + '</option>');
            //        }

            //        $("#orientations").empty();
            //        $("#orientations").append(' <option value="0">全部</option>');
            //        for (var i = 0; i < data.orientation.length; i++) {
            //            $("#orientations").append(' <option value="' + data.orientation[i].id + '">' + data.orientation[i].text + '</option>');
            //        }
            //        $("#houseTradeType").empty();
            //        for (var i = 0; i < data.houseTradeType.length; i++) {
            //            $("#houseTradeType").append(' <option value="' + data.houseTradeType[i].id + '">' + data.houseTradeType[i].text + '</option>');
            //        }

            //    }
            //});

            //$("#insertBtn").click(function () {
            //    var index = layer.open({
            //        type: 2,
            //        title: '添加房源',
            //        shadeClose: false,
            //        shade: 0.4,
            //        area: ['800px', '600px'],
            //        move: false,
            //        content: '/HouseSource/Insert',
            //        end: function () {
            //            $table.bootstrapTable('refresh');
            //        }
            //    });
            //    layer.full(index);
            //});
            //$("#editBtn").click(function () {
            //    var selected = $table.bootstrapTable('getSelections');

            //    if (selected.length > 1) {
            //        layer.msg("一次只能修改一条数据！", { icon: 5, time: 2000 });
            //        return;
            //    }

            //    if (selected.length == 0) {
            //        layer.msg("请选择您要修改的数据！", { icon: 5, time: 2000 });
            //        return;
            //    }
            //    var index = layer.open({
            //        type: 2,
            //        title: '修改房源',
            //        shadeClose: false,
            //        shade: 0.4,
            //        area: ['800px', '600px'],
            //        move: false,
            //        content: '/HouseSource/Insert?id=' + selected[0].id,
            //        end: function () {
            //            $table.bootstrapTable('refresh');
            //        }
            //    });
            //    layer.full(index);
            //});
            //$("#deleteBtn").click(function () {
            //    var selected = $table.bootstrapTable('getSelections');
            //    if (selected.length == 0) {
            //        layer.msg("请选择您要删除的数据！", { icon: 5, time: 2000 });
            //        return;
            //    }

            //    var arr = [];
            //    for (var i = 0; i < selected.length; i++) {
            //        arr.push(selected[i].id);
            //    }
            //    var ids = arr.join(",");

            //    layer.confirm('您确定要删除所选数据吗', {
            //        btn: ['是的', '取消'] //按钮
            //    }, function (index, layero) {
            //        layer.close(index);
            //        $.ajax({
            //            url: "/HouseSource/DeleteAsync",
            //            type: "post",
            //            dataType: "json",
            //            data: { ids: ids },
            //            success: function (data) {
            //                //Info,Success,Warning,Error
            //                var type = data.type;
            //                if (type == 1) {
            //                    layer.msg(data.content,
            //                        {
            //                            icon: 6, time: 2000
            //                        },
            //                        function () {
            //                            $table.bootstrapTable('refresh');
            //                        });
            //                } else {
            //                    layer.msg(data.content, { icon: 5, time: 2000 });
            //                }
            //            }
            //        });
            //    }, function () {
            //        return;
            //    });
            //});
            //$("#repeatPhoneBtn").click(function () {
            //    $("#repeatPhone").val(true);
            //    $table.bootstrapTable('refresh');
            //    $("#repeatPhone").val(false);
            //});



            @*$("#mainForm2").submit(function () {
                var selected = $table.bootstrapTable('getSelections')[0];
                //设置数据
                console.info(selected);
                parent.HouseSource_Index_data = {};
                parent.HouseSource_Index_data.beginDate = "2010-01-01";
                parent.HouseSource_Index_data.endDate = "@DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")";
                //交易
                if ($("#selectParmeter_tradeType").prop("checked")) {
                    var houseTradeType = $("#houseTradeType option");
                    if (selected.tradeTypeName == "出售") {
                        for (var i = 0; i < houseTradeType.length; i++) {
                            if ($(houseTradeType[i]).text() == "求购") {
                                parent.HouseSource_Index_data.tradeType = $(houseTradeType[i]).attr("value");
                                break;
                            }
                        }

                    } else if (selected.tradeTypeName == "出租") {
                        for (var i = 0; i < houseTradeType.length; i++) {
                            if ($(houseTradeType[i]).text() == "求租") {
                                parent.HouseSource_Index_data.tradeType = $(houseTradeType[i]).attr("value");
                                break;
                            }
                        }
                    } else {
                        parent.HouseSource_Index_data.tradeType = 0;
                    }

                } else {
                    parent.HouseSource_Index_data.tradeType = 0;
                }
                //城区
                if ($("#selectParmeter_areaId").prop("checked")) {
                    parent.HouseSource_Index_data.areaId = selected.areaId;
                } else {

                }
                //片区
                if ($("#selectParmeter_streetId").prop("checked")) {
                    parent.HouseSource_Index_data.areaId = selected.areaId;
                }
                //片区
                if ($("#selectParmeter_streetId").prop("checked")) {
                    parent.HouseSource_Index_data.streetId = selected.streetId;
                }
                //用途
                if ($("#selectParmeter_purpose").prop("checked")) {
                    parent.HouseSource_Index_data.purpose = selected.purpose;
                }
                // 房型
                if ($("#selectParmeter_scale").prop("checked")) {
                    parent.HouseSource_Index_data.scale = selected.bedroomCount;
                }
                // 楼层
                if ($("#selectParmeter_floor").prop("checked")) {
                    parent.HouseSource_Index_data.floor = selected.floor;
                }
                // 面积
                if ($("#selectParmeter_square").prop("checked")) {
                    parent.HouseSource_Index_data.beginSquare = 0;
                    parent.HouseSource_Index_data.endSquare = selected.square;
                }
                //价格
                if ($("#selectParmeter_price").prop("checked")) {
                    parent.HouseSource_Index_data.beginPrice = 0;
                    parent.HouseSource_Index_data.endPrice = selected.saleTotal;
                }
                //打开房源页面并刷新
                parent.CustomerSource_Open();
                layer.close(houseToHouse_layerIndex);
                return false;
            });*@
            //var houseToHouse_layerIndex = 0;
            //$("#houseToCustomerBtn").click(function () {
            //    var selected = $table.bootstrapTable('getSelections');
            //    if (selected.length > 1) {
            //        layer.msg("一次只能匹配一个客源数据！", { icon: 5, time: 2000 });
            //        return;
            //    }

            //    if (selected.length == 0) {
            //        layer.msg("请选择您要匹配的客源！", { icon: 5, time: 2000 });
            //        return;
            //    }
            //    houseToHouse_layerIndex = layer.open({
            //        title: "客配房参数",
            //        type: 1,
            //        area: ['400px', '210px'],
            //        content: $("#selectParmeter"),
            //    });
            //});


            $("#RefreshBtn").click(function () {
                $table.bootstrapTable('refresh');
            });
        });






    </script>
</body>
</html>
